import curses

_colors = {} 

def __initColors__():
    # I have a big crow.
    col = {"m":curses.COLOR_MAGENTA,
           "y":curses.COLOR_YELLOW,

           "b":curses.COLOR_BLACK, 
           "i":curses.COLOR_BLUE,
           "g":curses.COLOR_GREEN,

           "c":curses.COLOR_CYAN,
           "r":curses.COLOR_RED,
           "w":curses.COLOR_WHITE}

    pair = 0
    curses.start_color()
    for (i,j) in col.items():
        for (k,l) in col.items():
            if i != k:
                pair += 1
                curses.init_pair(pair, l, j)
                _colors[(str(k)+str(i))] = pair     

def getColor(name):
    # If the colors haven't been initialized yet, initialize them        
    if len(_colors) == 0:
        __initColors__() 

    if name in _colors:
        return curses.color_pair(_colors[name])

    return curses.color_pair(_colors["wb"])
